<template>
  <div class="table-wrapper">
    <el-table
      :data="data"
      border
      class="custom-table"
      style="width: 100%" height="90%">
      <el-table-column
        prop="time"
        label="日期区间">
      </el-table-column>
      <el-table-column
        prop="name"
        label="食堂名称">
      </el-table-column>
      <el-table-column
        prop="count"
        label="总用电量">
      </el-table-column>
    </el-table>
<!--    <el-pagination-->
<!--      background-->
<!--      layout="prev, pager, next"-->
<!--      :current-page="params.page"-->
<!--      :page-size="15"-->
<!--      :pager-count="5"-->
<!--      @current-change="changePage"-->
<!--      :total="params.total">-->
<!--    </el-pagination>-->
  </div>
</template>

<script>
import portal from '@/api/portal'

export default {
  name: 'BusTable',
  props: ['params'],
  data () {
    return {
      statusList: [],
      data: []
    }
  },
  created () {
    this.getCantentChart()
  },
  computed: {
  },
  mounted () {
  },
  methods: {
    search () {
      this.params.page = 1
      this.getCantentChart()
    },
    async getCantentChart () {
      if (!this.params.room_class || !this.params.room_class.length) {
        this.$message.warning('请选择食堂')
        return
      }
      if (!this.params.time_type) {
        this.$message.warning('请选择时间类型')
        return
      }
      if (!this.params.start_time) {
        this.$message.warning('请选择开始时间')
        return
      }
      if (!this.params.end_time) {
        this.$message.warning('请选择结束时间')
        return
      }
      if (!this.params.type) {
        this.$message.warning('请选择展示类型')
        return
      }
      const params = {
        room_class: this.params.room_class && this.params.room_class.join(),
        time_type: this.params.time_type,
        start_time: this.params.start_time,
        end_time: this.params.end_time,
        type: this.params.type
      }
      const res = await portal.getCantentChart(params)
      if (res.data) {
        this.loading = true
        this.data = res.data
        setTimeout(() => {
          this.loading = false
        })
      }
    },
    changePage (val) {
      this.params.page = val
      this.getCantentChart()
    }
  }
}
</script>

<style scoped lang="scss">

</style>
